package com.wxtl.action;

import java.util.ArrayList;
import java.util.List;

import com.wxtl.action.base.BaseAction;
import com.wxtl.entity.Product;
import com.wxtl.service.ProductService;
import com.wxtl.util.Page;

public class ProductAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3593032531414222877L;
	
	private List<Product> allPro = new ArrayList<Product>();
	

	public List<Product> getAllPro() {
		return allPro;
	}
	public void setAllPro(List<Product> allPro) {
		this.allPro = allPro;
	}

	private ProductService productService;
	
	public ProductService getProductService() {
		return productService;
	}
	public void setProductService(ProductService productService) {
		this.productService = productService;
	}
	
	private int[] ids;
	private Product product =  new Product();
	
	public int[] getIds() {
		return ids;
	}
	public void setIds(int[] ids) {
		this.ids = ids;
	}
	public Product getProduct() {
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	
	//获取所有产品
	public String getAllProduct(){
		setAllPro(productService.getAllProduct());
		return SUCCESS;
	}
	
	
	public String add(){
		productService.add(product);
		return SUCCESS;
	}
	
	public String update(){
		productService.update(product);
		return SUCCESS;
	}
	
	public String delete(){
		productService.delete(ids);
		return SUCCESS;
	}
	
	public String query(){
		Page pageData=productService.query(super.getDataGrid(),product);
		setPageData(pageData);
		return SUCCESS;
	}

}
